package com.SunSoft.PhoneRemoteControl;

import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

final class bi
  implements DialogInterface.OnClickListener
{
  public final void onClick(DialogInterface paramDialogInterface, int paramInt)
  {
    int i;
    Object localObject;
    paramDialogInterface.dismiss();
    if (paramInt == 0)
    {
      if (!(MainControl.f))
        break label875;
      paramDialogInterface = MainControl.i(bh.a(this.a)).rawQuery("select ID,control_type,name_ch,name_en,brand_ch,brand_en,come_from,define_ID,control_model  from control_list where ID = ?", new String[] { String.valueOf(bh.a(this.a).T) });
      if (paramDialogInterface.moveToNext())
      {
        i = paramDialogInterface.getInt(paramDialogInterface.getColumnIndex("come_from"));
        int j = paramDialogInterface.getInt(paramDialogInterface.getColumnIndex("control_type"));
        localObject = paramDialogInterface.getString(paramDialogInterface.getColumnIndex("define_ID"));
        if (j != 5)
          break label577;
        Toast.makeText(bh.a(this.a), bh.a(this.a).getString(2131099805), 0).show();
      }
      paramDialogInterface.close();
    }
    if (paramInt == 1)
      bh.a(this.a).a(false);
    if (paramInt == 2)
    {
      localObject = MainControl.i(bh.a(this.a)).rawQuery("select ID,control_type,name_ch,name_en,brand_ch,brand_en,control_model  from control_list where ID = ?", new String[] { String.valueOf(bh.a(this.a).T) });
      paramDialogInterface = "";
      if (((Cursor)localObject).moveToNext())
        paramDialogInterface = ((Cursor)localObject).getString(((Cursor)localObject).getColumnIndex(bh.a(this.a).w));
      new AlertDialog.Builder(bh.a(this.a)).setTitle(MainControl.g(bh.a(this.a))).setMessage(bh.a(this.a).getString(2131099806) + paramDialogInterface).setNegativeButton(bh.a(this.a).getString(2131099654), new bj(this)).setPositiveButton(bh.a(this.a).getString(2131099653), new bk(this)).show();
    }
    if (paramInt == 3)
    {
      if (bh.a(this.a).bq != bh.a(this.a).T)
        break label935;
      Toast.makeText(bh.a(this.a), bh.a(this.a).getString(2131099815), 0).show();
      MainControl.d(bh.a(this.a)).a("default_id", "0");
      bh.a(this.a).bq = 0;
    }
    while (true)
    {
      while (true)
      {
        label577: Cursor localCursor;
        if (paramInt == 4)
        {
          bh.a(this.a).bD = bh.a(this.a).T;
          paramDialogInterface = new Message();
          paramDialogInterface.what = 17;
          bh.a(this.a).ca.sendMessage(paramDialogInterface);
        }
        if (paramInt == 5)
        {
          bh.a(this.a).bD = bh.a(this.a).T;
          paramDialogInterface = new Message();
          paramDialogInterface.what = 23;
          bh.a(this.a).ca.sendMessage(paramDialogInterface);
        }
        if (paramInt == 6)
        {
          paramDialogInterface = new Message();
          paramDialogInterface.what = 22;
          bh.a(this.a).ca.sendMessage(paramDialogInterface);
        }
        return;
        if (i <= 2)
        {
          MainControl.i(bh.a(this.a)).execSQL("update control_list set come_from = ? where ID= ? ", new String[] { "4", String.valueOf(bh.a(this.a).T) });
          localCursor = MainControl.f(bh.a(this.a)).rawQuery("select ID,control_ID,code_str,dis_ch,dis_en,note,order_ID,define_ID  from button_data where define_ID = ? order by order_ID", new String[] { localObject });
        }
        while (true)
        {
          while (!(localCursor.moveToNext()))
          {
            localCursor.close();
            localObject = new Intent(bh.a(this.a), Show_Control.class);
            ((Intent)localObject).putExtra("con_id", String.valueOf(bh.a(this.a).T));
            ((Intent)localObject).putExtra("do_type", "2");
            bh.a(this.a).startActivity((Intent)localObject);
          }
          Object[] arrayOfObject = new Object[8];
          arrayOfObject[1] = localObject;
          arrayOfObject[2] = Integer.valueOf(0);
          arrayOfObject[3] = localCursor.getString(localCursor.getColumnIndex("code_str"));
          arrayOfObject[4] = localCursor.getString(localCursor.getColumnIndex("dis_ch"));
          arrayOfObject[5] = localCursor.getString(localCursor.getColumnIndex("dis_en"));
          arrayOfObject[6] = localCursor.getString(localCursor.getColumnIndex("note"));
          arrayOfObject[7] = Integer.valueOf(localCursor.getInt(localCursor.getColumnIndex("order_ID")));
          MainControl.i(bh.a(this.a)).execSQL("insert into button_data (ID,define_ID,control_ID,code_str,dis_ch,dis_en,note,order_ID) values (?,?,?,?,?,?,?,?) ", arrayOfObject);
        }
        label875: paramDialogInterface = new Intent(bh.a(this.a), Show_Control.class);
        paramDialogInterface.putExtra("con_id", String.valueOf(bh.a(this.a).T));
        paramDialogInterface.putExtra("do_type", "1");
        bh.a(this.a).startActivity(paramDialogInterface);
      }
      label935: bh.a(this.a).bq = bh.a(this.a).T;
      MainControl.d(bh.a(this.a)).a("default_id", String.valueOf(bh.a(this.a).T));
      Toast.makeText(bh.a(this.a), bh.a(this.a).getString(2131099814), 0).show();
    }
  }
}